package br.com.lambdacore.validator.impl;

import br.com.lambdacore.validator.Validator;

public final class NumberValidator extends Validator<Number> {

	private static final long ZERO = 0L;

	protected NumberValidator(Number number) {
		super(number);
	}

	public boolean atLeast(Number number) {
		return this.greaterEqualThan(number);
	}

	@Override
	public boolean equalThan(Number number) {
		return this.getObject().longValue() == number.longValue();
	}

	public boolean greaterEqualThan(Number number) {
		return this.getObject().longValue() >= number.longValue();
	}

	public boolean greaterThan(Number number) {
		return this.getObject().longValue() > number.longValue();
	}

	public boolean lessEqualThan(Number number) {
		return this.getObject().longValue() <= number.longValue();
	}

	public boolean lessThan(Number number) {
		return this.getObject().longValue() < number.longValue();
	}

	public boolean notNullOrZero() {
		return !this.nullOrZero();
	}

	public boolean notZero() {
		return !this.zero();
	}

	public boolean nullOrZero() {
		return this.nil() || this.zero();
	}

	public boolean upTo(Number number) {
		return this.lessEqualThan(number);
	}

	public boolean zero() {
		return this.equalThan(ZERO);
	}

	public static NumberValidator is(Number number) {
		return new NumberValidator(number);
	}

}
